<template>
  <view>
    <!-- 酒体风格 -->
    <template v-if="type === 'flavor'">
      <view v-for="(item, index) in flavorList" :key="'flavor' + index" class="form-item">
        <text class="label">
          {{ item.label }}
          <text v-if="item.subLabel" style="font-size: 27rpx">{{ item.subLabel }}</text>
        </text>
        <Custom-input
          v-model="form[item.value]"
          :type="item.type"
          :suffix="item.suffix"
          :maxlength="item.maxlength"
          :options="item.options"
          :placeholder="item.placeholder"
          :keyName="item.keyName"
          :keyValue="item.keyValue"
          :disabled="disabled"
        />
      </view>
    </template>

    <!-- 品鉴细化 -->
    <template v-else-if="type === 'tasting'">
      <!-- 一、香气 -->
      <view class="label">一、香气</view>
      <view v-for="(item, index) in tastList1" :key="'tast1' + index" class="form-item">
        <text class="label">
          {{ item.label }}
          <text v-if="item.subLabel" style="font-size: 27rpx">{{ item.subLabel }}</text>
        </text>
        <Custom-input
          v-model="form[item.value]"
          :type="item.type"
          :suffix="item.suffix"
          :maxlength="item.maxlength"
          :options="item.options"
          :placeholder="item.placeholder"
          :keyName="item.keyName"
          :keyValue="item.keyValue"
          :disabled="disabled"
        />
      </view>
      <!-- 二、口感—入口 -->
      <view class="label">二、口感—入口</view>
      <view v-for="(item, index) in tastList2" :key="'tast2' + index" class="form-item">
        <text class="label">
          {{ item.label }}
          <text v-if="item.subLabel" style="font-size: 27rpx">{{ item.subLabel }}</text>
        </text>
        <Custom-input
          v-model="form[item.value]"
          :type="item.type"
          :suffix="item.suffix"
          :maxlength="item.maxlength"
          :options="item.options"
          :placeholder="item.placeholder"
          :keyName="item.keyName"
          :keyValue="item.keyValue"
          :disabled="disabled"
        />
      </view>
      <!-- 三、口感—味中 -->
      <view class="label">三、口感—味中</view>
      <view v-for="(item, index) in tastList3" :key="'tast3' + index" class="form-item">
        <text class="label">
          {{ item.label }}
          <text v-if="item.subLabel" style="font-size: 27rpx">{{ item.subLabel }}</text>
        </text>
        <Custom-input
          v-model="form[item.value]"
          :type="item.type"
          :suffix="item.suffix"
          :maxlength="item.maxlength"
          :options="item.options"
          :placeholder="item.placeholder"
          :keyName="item.keyName"
          :keyValue="item.keyValue"
          :disabled="disabled"
        />
      </view>
      <!-- 四、口感—余味 -->
      <view class="label">四、口感—余味</view>
      <view v-for="(item, index) in tastList4" :key="'tast4' + index" class="form-item">
        <text class="label">
          {{ item.label }}
          <text v-if="item.subLabel" style="font-size: 27rpx">{{ item.subLabel }}</text>
        </text>
        <Custom-input
          v-model="form[item.value]"
          :type="item.type"
          :suffix="item.suffix"
          :maxlength="item.maxlength"
          :options="item.options"
          :placeholder="item.placeholder"
          :keyName="item.keyName"
          :keyValue="item.keyValue"
          :disabled="disabled"
        />
      </view>
      <!-- 五、口感—饮后 -->
      <view class="label">五、口感—饮后</view>
      <view v-for="(item, index) in tastList5" :key="'tast5' + index" class="form-item">
        <text class="label">
          {{ item.label }}
          <text v-if="item.subLabel" style="font-size: 27rpx">{{ item.subLabel }}</text>
        </text>
        <Custom-input
          v-model="form[item.value]"
          :type="item.type"
          :suffix="item.suffix"
          :maxlength="item.maxlength"
          :options="item.options"
          :placeholder="item.placeholder"
          :keyName="item.keyName"
          :keyValue="item.keyValue"
          :disabled="disabled"
        />
      </view>
      <view class="label">六、酒体结构</view>
      <view v-for="(item, index) in tastList6" :key="'tast6' + index" class="form-item">
        <text class="label">
          {{ item.label }}
          <text v-if="item.subLabel" style="font-size: 27rpx">{{ item.subLabel }}</text>
        </text>
        <Custom-input
          v-model="form[item.value]"
          :type="item.type"
          :suffix="item.suffix"
          :maxlength="item.maxlength"
          :options="item.options"
          :placeholder="item.placeholder"
          :keyName="item.keyName"
          :keyValue="item.keyValue"
          :disabled="disabled"
        />
      </view>
    </template>

    <!-- 优化方向 -->
    <template v-else-if="type === 'optimizeDirection'">
      <view
        v-for="(item, index) in optimizeList"
        :key="'optimize' + index"
        class="form-item"
      >
        <text class="label">
          {{ item.label }}
          <text v-if="item.subLabel" style="font-size: 27rpx">{{ item.subLabel }}</text>
        </text>
        <Custom-input
          v-model="form[item.value]"
          :type="item.type"
          :suffix="item.suffix"
          :maxlength="item.maxlength"
          :options="item.options"
          :placeholder="item.placeholder"
          :keyName="item.keyName"
          :keyValue="item.keyValue"
          :disabled="disabled"
        />
      </view>
    </template>

    <!-- 优化细化 -->
    <template v-else-if="type === 'optimizeDetail'">
      <!-- 一、酒精度期望范围 -->
      <template v-if="form?.direction?.includes('酒精度调整')">
        <text class="label">一、酒精度期望范围</text>
        <view
          v-for="(item, index) in detailList1"
          :key="'detail1' + index"
          class="form-item"
        >
          <text class="label">
            {{ item.label }}
            <text v-if="item.subLabel" style="font-size: 27rpx">{{ item.subLabel }}</text>
          </text>
          <Custom-input
            v-model="form[item.value]"
            :type="item.type"
            :suffix="item.suffix"
            :maxlength="item.maxlength"
            :options="item.options"
            :placeholder="item.placeholder"
            :keyName="item.keyName"
            :keyValue="item.keyValue"
            :disabled="disabled"
          />
        </view>
        </template>
      <!-- 二、原有基础上香气调整 -->
      <template v-if="form?.direction?.includes('香气调整')">
        <view class="label">二、原有基础上香气调整</view>
        <view
          v-for="(item, index) in detailList2"
          :key="'detail2' + index"
          class="form-item"
        >
          <text class="label">
            {{ item.label }}
            <text v-if="item.subLabel" style="font-size: 27rpx">{{ item.subLabel }}</text>
          </text>
          <Custom-input
            v-model="form[item.value]"
            :type="item.type"
            :suffix="item.suffix"
            :maxlength="item.maxlength"
            :options="item.options"
            :placeholder="item.placeholder"
            :keyName="item.keyName"
            :keyValue="item.keyValue"
            :disabled="disabled"
          />
        </view>
      </template>
      <!-- 三、原有基础上口感调整——入口 -->
      <template v-if="form?.direction?.includes('口感调整')">
        <view class="label">三、原有基础上口感调整——入口</view>
        <view
          v-for="(item, index) in detailList3"
          :key="'detail3' + index"
          class="form-item"
        >
          <text class="label">
            {{ item.label }}
            <text v-if="item.subLabel" style="font-size: 27rpx">{{ item.subLabel }}</text>
          </text>
          <Custom-input
            v-model="form[item.value]"
            :type="item.type"
            :suffix="item.suffix"
            :maxlength="item.maxlength"
            :options="item.options"
            :placeholder="item.placeholder"
            :keyName="item.keyName"
            :keyValue="item.keyValue"
            :disabled="disabled"
          />
        </view>
      </template>
      <!-- 四、原有基础上余味调整 -->
      <template v-if="form?.direction?.includes('余味调整')">
        <view class="label">四、原有基础上余味调整</view>
        <view
          v-for="(item, index) in detailList4"
          :key="'detail4' + index"
          class="form-item"
        >
          <text class="label">
            {{ item.label }}
            <text v-if="item.subLabel" style="font-size: 27rpx">{{ item.subLabel }}</text>
          </text>
          <Custom-input
            v-model="form[item.value]"
            :type="item.type"
            :suffix="item.suffix"
            :maxlength="item.maxlength"
            :options="item.options"
            :placeholder="item.placeholder"
            :keyName="item.keyName"
            :keyValue="item.keyValue"
            :disabled="disabled"
          />
        </view>
      </template>
    </template>
    <!-- 饮用场景与特殊需求 -->
    <template v-else-if="type === 'scene'">
      <view v-for="(item, index) in sceneList" :key="'scene' + index" class="form-item">
        <text class="label">
          {{ item.label }}
          <text v-if="item.subLabel" style="font-size: 27rpx">{{ item.subLabel }}</text>
        </text>
        <Custom-input
          v-model="form[item.value]"
          :type="item.type"
          :suffix="item.suffix"
          :maxlength="item.maxlength"
          :options="item.options"
          :placeholder="item.placeholder"
          :keyName="item.keyName"
          :keyValue="item.keyValue"
          :disabled="disabled"
        />
      </view>
    </template>
  </view>
</template>

<script setup>
import { ref } from "vue";
import CustomInput from "./CustomInput.vue";
const props = defineProps({
  type: String, // 'flavor' 或 'tasting'
  form: Object,
  disabled: {
    // 是否禁用
    type: Boolean,
    default: false,
  },
});
const emit = defineEmits(["update:form"]);
const flavorList = ref([
  {
    label: "1、香型选择",
    value: "aromaType",
    type: "select",
    options: ["酱香", "浓香", "清香", "米香", "复合香型", "其他"],
    placeholder: "请选择...",
  },
  {
    label: "2、酒精度期望范围",
    subLabel: "（可填区间：25-60%）",
    value: "alcoholRange",
    maxlength: 2,
    type: "input",
    suffix: "%vol",
  },
  {
    label: "3、口感偏好",
    subLabel: "（可多选）",
    value: "taste",
    type: "checkbox",
    options: ["醇厚绵柔", "清爽干净", "辛辣热烈", "甘甜圆润", "层次丰富"],
    placeholder: "请选择...",
  },
  {
    label: "4、风味关键词",
    subLabel: "（如：果香/木香/烟熏等）",
    value: "flavour",
    type: "input",
  },
  { label: "5、酒体价格区间", value: "priceRange", type: "input", suffix: "元" },
]);
const tastList1 = ref([
  {
    label: "1、强度偏好",
    value: "intensity",
    type: "select",
    options: ["淡雅", "适中", "浓郁"],
    placeholder: "请选择...",
  },
  {
    label: "2、层次感",
    value: "layer",
    type: "select",
    options: ["单一纯粹", "多重变化"],
    placeholder: "请选择...",
  },
  {
    label: "3、幽雅馥郁舒适突出",
    value: "comfort",
    type: "select",
    options: ["陈香", "窖香", "粮香", "果香"],
    placeholder: "请选择...",
  },
  {
    label: "4、特别要求",
    subLabel: "（如酒中有老窖泥香等香气）",
    maxlength: 50,
    value: "demand",
    type: "input",
  },
]);
const tastList2 = ref([
  {
    label: "1、入口感受",
    value: "lips",
    type: "select",
    options: ["顺滑", "刺激", "微涩", "油润感"],
    placeholder: "请选择...",
  },
  {
    label: "2、甜/苦/酸平衡",
    subLabel: "（可填比例，如甜:苦=7:3）",
    maxlength: 50,
    value: "lipsTaste",
    type: "input",
  },
  {
    label: "3、喷香强度",
    value: "tasteStrength",
    type: "select",
    options: ["无喷香", "一般", "舒适", "喷发散开"],
    placeholder: "请选择...",
  },
]);
const tastList3 = ref([
  {
    label: "1、醇厚丰满感受",
    value: "richFeel",
    type: "select",
    options: ["单薄", "纯正", "醇厚", "浓郁"],
    placeholder: "请选择...",
  },
  {
    label: "2、谐调圆润感受",
    value: "harmoniousFeel",
    type: "select",
    options: ["单调", "谐调", "和谐"],
    placeholder: "请选择...",
  },
]);
const tastList4 = ref([
  {
    label: "1、持续时间",
    value: "sustain",
    type: "select",
    options: ["短暂", "适中", "悠长"],
    placeholder: "请选择...",
  },
  {
    label: "2、回味倾向",
    value: "aftertaste",
    type: "select",
    options: ["干净利落", "回甜爽口", "细腻持久"],
    placeholder: "请选择...",
  },
]);
const tastList5 = ref([
  {
    label: "1、酒体个性",
    value: "personality",
    type: "select",
    options: ["个性一般", "风格突出", "风格典型", "格调高雅"],
    placeholder: "请选择...",
  },
  {
    label: "2、醉酒",
    value: "drunkSpeed",
    type: "select",
    options: ["快", "慢"],
    placeholder: "请选择...",
  },
  {
    label: "2、醒酒",
    value: "wakeSpeed",
    type: "select",
    options: ["快", "慢"],
    placeholder: "请选择...",
  },
]);
const tastList6 = ref([
  {
    label: "1、复杂度",
    value: "complexity",
    type: "select",
    options: ["简单直接", "中等层次", "复杂深邃"],
    placeholder: "请选择...",
  },
  {
    label: "2、平衡度偏好",
    value: "balance",
    type: "select",
    options: ["某风味突出", "整体均衡"],
    placeholder: "请选择...",
  },
]);
const optimizeList = ref([
  {
    label: "1、优化方向",
    subLabel: "（可多选）",
    value: "direction",
    type: "checkbox",
    options: ["酒精度调整", "香气调整", "口感调整", "余味调整"],
    placeholder: "请选择...",
  },
  {
    label: "2、其他调整说明",
    value: "remark",
    maxlength: 50,
    type: "input",
  },
  {
    label: "3、酒体价格区间",
    value: "priceRange",
    type: "input",
    suffix: "元",
  },
]);
const detailList1 = ref([
  {
    label: "1、酒精度期望范围",
    subLabel: "（可填区间：25-60%）",
    maxlength: 2,
    value: "alcoholRange",
    type: "input",
    suffix: "%vol",
  },
]);
const detailList2 = ref([
  {
    label: "1、香气调整",
    value: "intensity",
    type: "select",
    options: ["减弱", "加强"],
    placeholder: "请选择...",
  },
  {
    label: "2、层次感调整",
    value: "layer",
    type: "select",
    options: ["单一纯粹", "多重变化"],
    placeholder: "请选择...",
  },
  {
    label: "3、幽雅馥郁舒适突出",
    value: "comfort",
    type: "select",
    options: ["陈香", "窖香", "粮香", "果香"],
    placeholder: "请选择...",
  },
  {
    label: "4、特别要求",
    subLabel: "（如酒中有老窖泥香、陈曲香、炒芝麻焦香、植物花香等令人舒适愉悦的香气）",
    maxlength: 50,
    value: "demand",
    type: "input",
  },
]);
const detailList3 = ref([
  {
    label: "1、入口感受加强",
    value: "lips",
    type: "select",
    options: ["顺滑", "刺激", "微涩", "油润感"],
    placeholder: "请选择...",
  },
  {
    label: "2、甜/苦/酸平衡",
    subLabel: "（可填比例，如甜:苦=7:3）",
    maxlength: 50,
    value: "lipsTaste",
    type: "input",
  },
  {
    label: "3、喷香强度",
    value: "tasteStrength",
    type: "select",
    options: ["无喷香", "一般", "舒适", "喷发散开"],
    placeholder: "请选择...",
  },
]);
const detailList4 = ref([
  {
    label: "1、持续时间",
    value: "sustain",
    type: "select",
    options: ["减弱", "加强"],
    placeholder: "请选择...",
  },
  {
    label: "2、回味倾向",
    value: "aftertaste",
    type: "select",
    options: ["干净利落", "回甜爽口", "细腻持久"],
    placeholder: "请选择...",
  },
]);
const sceneList = ref([
  {
    label: "1、主要饮用场景",
    value: "scene",
    type: "select",
    options: ["日常自饮", "聚会分享", "商务宴请", "收藏陈酿", "礼品馈赠"],
    placeholder: "请选择...",
  },
  {
    label: "2、预计需求量",
    subLabel: "（1件6瓶计）",
    value: "quantity",
    type: "select",
    options: ["10件", "30件", "50件", "其他"],
    placeholder: "请选择...",
  },
  {
    label: "2、其他特殊要求",
    value: "specialNeeds",
    maxlength: 50,
    type: "input",
  },
]);
</script>
<style scoped>
.form-item {
  margin-bottom: 18rpx;
}

.label {
  font-size: 34rpx;
  color: #3d3d3d;
  min-width: 180rpx;
  margin-bottom: 18rpx;
}
</style>
